extends TouchScreenButton

@export var texture_dict: Dictionary = {
	Player.HoldItem.None: null, 
	Player.HoldItem.Axe: null, 
	Player.HoldItem.Hoe: null, 
	Player.HoldItem.Kettle: null, 
}


func _process(delta: float) -> void:
	var player: Player = Player.get_instance()
	if !player: 
		return
	var cur_hold_item = player.hold_item
	# 更新手持物品UI图片
	texture_normal = texture_dict[int(cur_hold_item)]
	# 如果按下切换键
	if Input.is_action_just_pressed("cg_item"):
		# 更新玩家手持物品
		var next_hold_item_index = int(cur_hold_item) + 1
		next_hold_item_index %= player.HoldItem.size()
		var next_hold_item = Player.HoldItem.values()[next_hold_item_index]
		player.hold_item = next_hold_item
		print("切换手持物品到: ", next_hold_item_index, ": ", Player.HoldItemNames[next_hold_item])
